package org.thunms.framework.log4j;

import java.io.FileNotFoundException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.web.util.WebUtils;
import org.thunms.framework.utils.UtilSystemProperties;
public class Log4jListener implements ServletContextListener {
	@Override
	public void contextInitialized(ServletContextEvent event) {
		try {
			UtilSystemProperties.setThunmsWebappRoot(WebUtils.getRealPath(event.getServletContext(),"/"));
			System.setProperty("thunms.home", UtilSystemProperties.getThunmsWebappRoot());
			System.out.println("系统属性thunms.webapp.root===》"+UtilSystemProperties.getThunmsWebappRoot());
		} catch (FileNotFoundException e1) {
			System.err.print("属性thunms.webapp.root设置失败,系统无法正常运行");
			System.exit(0);
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent event) {
		
	}
	
	
}
